﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using ArgusLight.Drawing;
using ArgusControls;
using ArgusLight.Fractals2D;
using ArgusLight.Fractals2D.ComplexFractalColoring;
using ArgusLight.Fractals2D.ComplexFractalColoring.RouteLengthBased;

namespace Fractals
{
	public partial class UIRouteLengthUserColoringParameter : UIColoringParameter
	{
		public UIRouteLengthUserColoringParameter()
		{
			InitializeComponent();
			this.cColorOne.SetEnumType(typeof(ColorEnum));
			this.cColorTwo.SetEnumType(typeof(ColorEnum));
			this.SetColorNames();
			this.uiElementPeriodicColoringParameter.RedrawRequested += uiElementPeriodicColoringParameter_RedrawRequested;
		}

		private void SetColorNames()
		{
			foreach (EnumComboBoxItem cbi in this.cColorOne.Items)
			{
				cbi.Content = Localization.Colors.ResourceManager.GetString(cbi.EnumName);
			}
			foreach (EnumComboBoxItem cbi in this.cColorTwo.Items)
			{
				cbi.Content = Localization.Colors.ResourceManager.GetString(cbi.EnumName);
			}
		}

		void uiElementPeriodicColoringParameter_RedrawRequested(object sender, EventArgs e)
		{
			this.OnRedrawRequested();
		}

		private void cColorOne_SelectionChanged(object sender, SelectionChangedEventArgs e)
		{
			this.OnRedrawRequested();
		}

		private void cColorTwo_SelectionChanged(object sender, SelectionChangedEventArgs e)
		{
			this.OnRedrawRequested();
		}

		public override void SetValues(ArgusLight.Fractals2D.ColoringParameter cParameter)
		{
			this.uiElementPeriodicColoringParameter.SetValues(cParameter);
			UserColoringParameter para = (UserColoringParameter)cParameter;
			this.cColorOne.Select((ColorEnum)para.ColorOne.ToInt());
			this.cColorTwo.Select((ColorEnum)para.ColorTwo.ToInt());
		}

		public override void GetValues(ref ArgusLight.Fractals2D.ColoringParameter cParameter)
		{
			this.uiElementPeriodicColoringParameter.GetValues(ref cParameter);
			UserColoringParameter para = (UserColoringParameter)cParameter;
			para.ColorOne = ((ColorEnum)this.cColorOne.SelectedEnum).ToColor();
			para.ColorTwo = ((ColorEnum)this.cColorTwo.SelectedEnum).ToColor();
			cParameter = para;
		}
	}
}
